﻿<telerik:RadWindow x:Class="CP.NLayer.Client.WpfClient.Modules.Admin.Role.RoleEditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:common="clr-namespace:CP.NLayer.Client.WpfClient.Common;assembly=CP.NLayer.Client.WpfClient.Common"
    common:DialogCloser.RadDialogResult="{Binding DialogResult}"
        xmlns:l="http://wpflocalizeextension.codeplex.com"
        l:LocalizeDictionary.DesignCulture="en"
        l:ResxLocalizationProvider.DefaultAssembly="CP.NLayer.Resources"
        l:ResxLocalizationProvider.DefaultDictionary="MResources"
    mc:Ignorable="d" Width="443" Height="325"
    Header="{Binding ViewHeader}" ResizeMode="NoResize"
    WindowStartupLocation="CenterScreen">

    <telerik:RadWindow.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <Style TargetType="TextBox" BasedOn="{StaticResource TextBoxErrorStyle}">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
    </telerik:RadWindow.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="35" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" DataContext="{Binding Item}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="10"/>
                <ColumnDefinition />
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <!--column 1-->
            <TextBlock Grid.Column="1" Text="{l:Loc Role_Name}" />
            <TextBlock Grid.Row="1" Grid.Column="1" Text="{l:Loc Description}" />
            <!--column 3-->
            <TextBox Text="{Binding Role.Name, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Column="3" />
            <TextBox Text="{Binding Role.Description, Mode=TwoWay, ValidatesOnDataErrors=True}" Grid.Row="1" Grid.Column="3" Grid.RowSpan="2"
                     AcceptsReturn="True" TextWrapping="Wrap" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" />
            <!--column 5-->
            <CheckBox x:Name="selectAllCheckBox" Grid.Column="5" Margin="0,10,0,0" Content="{l:Loc PermissionList, Dict=UiResources}" FlowDirection="RightToLeft" HorizontalAlignment="Left" />
            <telerik:RadListBox x:Name="radListBox" Grid.Column="5" Grid.Row="1" Grid.RowSpan="5"
                                ItemsSource="{Binding Item.PermissionList}" SelectionMode="Multiple" >
                <telerik:RadListBox.ItemContainerStyle>
                    <Style TargetType="telerik:RadListBoxItem">
                        <Setter Property="IsSelected" Value="{Binding Checked, Mode=TwoWay}"/>
                    </Style>
                </telerik:RadListBox.ItemContainerStyle>
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Content="{Binding Text}" IsChecked="{Binding Path=IsSelected, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadListBoxItem}}}"/>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
            </telerik:RadListBox>
        </Grid>
        <!--row 1-->
        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
            <telerik:RadButton Content="Save" Width="60" Margin="8 0" VerticalAlignment="Center" Command="{Binding SaveCommand}" />
            <telerik:RadButton Content="Cancel" Width="60" Margin="0 0 10 0" VerticalAlignment="Center" Command="{Binding CancelCommand}" IsCancel="True"/>
        </StackPanel>

    </Grid>
</telerik:RadWindow>
